<?php
//dicts Model
class ParamsModel
{
	var $id;
	var $param;
	var $value;
	/*SET*/
	public function setId($id)
	{
		$this->id=$id;
		}
	public function setParam($param)
	{
		$this->param=$param;
		}
	public function setValue($value)
	{
		$this->value=$value;
		}
		/*GET*/
	public function getId()
	{
		return $this->id;
		}
	public function getParam()
	{
		return $this->param;
		}
	public function getValue()
	{
		return $this->value;
		}
}
class ParamsQuery
{
	private $param;
	
	public function ParamsQuery($param="")
	{
		$this->param=new ParamsModel();
		if($param!="")
		{
			$this->param=$param;
			echo $this->param->getId();
		}
	}
		public function inserQuery()
		{
			$q="INSERT INTO `laodicts`.`Params` (`param`, `value`) VALUES ('%s', '%s');";
			$q=sprintf($q,
			mysql_escape_string($this->param->getParam()),
			mysql_escape_string($this->param->getValue()));
		//die($q);
		return	mysql_query($q);
		}
		public function updateQuery()
		{
			$q="UPDATE `laodicts`.`Params` SET `param` = %s,
			`value` = %s,
			WHERE `packages`.`id` =%d ";

			$q=sprintf($q,
						mysql_escape_string($this->param->getParam()),
						mysql_escape_string($this->param->getValue()),
						mysql_escape_string($this->param->getId()));
		
			return mysql_query($q);
			}
		public function deleteQuery()
		{
			$q="delete Params where id=%d";
			$q=sprintf($q,mysql_escape_string($this->param->getId()));
			return mysql_query($q);
			}
		public function selectLanguageQuery($val)
		{
			 
			$arr=array();
			
			
			$i=0;
			$query=sprintf("SELECT * FROM Params where param like '%s'",mysql_escape_string($val));

			$result=mysql_query($query);
			$num=mysql_numrows($result);
			
			while ($i < $num) {
				$this->param=new ParamsModel();
			
			$this->param->setId(mysql_result($result,$i,"id"));
			$this->param->setParam(mysql_result($result,$i,"param"));
			$this->param->setValue(mysql_result($result,$i,"value"));
						
			$arr[]=$this->param;
			
			}
			
			return $arr;
		}
		
		public function selectParamByID($id)
		{
			 
			$i=0;
			$query=sprintf("SELECT * FROM Params where id = %d",mysql_escape_string($id));

			$result=mysql_query($query);
			$num=mysql_numrows($result);
			
			while ($i < $num) {
				$this->param=new ParamsModel();
			
			$this->param->setId(mysql_result($result,$i,"id"));
			$this->param->setParam(mysql_result($result,$i,"param"));
			$this->param->setValue(mysql_result($result,$i,"value"));				
			}
			return $this->param;
		}
}
?>
